package com.party.admin.biz.cMember;

import com.google.common.collect.Maps;
import com.party.common.utils.DateUtils;
import com.party.core.model.commune.CMemberInfo;
import com.party.core.service.commune.ICMemberInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;
import java.util.List;

@Service
public class CMemberBizService {
    @Autowired
    private ICMemberInfoService memberInfoService;


    public void refreshExpirationStatus() throws Exception{
        HashMap<String, Object> params = Maps.newHashMap();
        params.put("effectiveTime", DateUtils.formatDate(new Date()));
        List<CMemberInfo> cMemberInfos = memberInfoService.queryEffectiveCMembers(params);
        for (CMemberInfo  cMemberInfo:cMemberInfos) {
            cMemberInfo.setMemberGrade(CMemberInfo.MEMBER_GRADE_ORDINARY);
            memberInfoService.update(cMemberInfo);
        }
    }
}
